package com.zhu.storesmanager.views;

import java.util.List;

import com.zhu.storesmanager.R;
import com.zhu.storesmanager.models.DataItem;
import com.zhu.storesmanager.utils.ViewsUtil;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.LinearLayout;

/**
 * 竞品促销活动
 */
public class PromotionsView extends LinearLayout implements OnClickListener{

    private ChoiceView mBrandChoiceview = null; //品牌
    private EditText mModelEditText = null; //型号
    private EditText mPriceEditText = null; //价格
    private EditText mSellcountEditText = null; //销量
    private EditText mOtherEditText = null; //其他活动
    private ChoiceView mPromotionsChoiceview = null; //活动形式
    
    private LinearLayout mBodyLinearLayout = null; //新增项

    public PromotionsView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }

    public PromotionsView(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }

    public PromotionsView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        // TODO Auto-generated constructor stub
    }

    /**
     * 界面加载完成
     * (non-Javadoc)
     * @see android.view.View#onFinishInflate()
     */
    public void onFinishInflate(){
        mBrandChoiceview = ViewsUtil.setChoiceView(findViewById(R.id.compete_brands), R.string.sales_brands);
        mModelEditText = ViewsUtil.setEditTextView(findViewById(R.id.compete_model), R.string.model);
        mPriceEditText = ViewsUtil.setEditTextView(findViewById(R.id.compete_price), R.string.price);
        mSellcountEditText = ViewsUtil.setEditTextView(findViewById(R.id.compete_sellcount), R.string.salescount);
        mPromotionsChoiceview = ViewsUtil.setChoiceView(findViewById(R.id.compete_promotions), R.string.compete_activity);
        mPromotionsChoiceview.setMultiChoice();
        mOtherEditText = ViewsUtil.setEditTextView(findViewById(R.id.compete_otherpromotions), R.string.compete_otheractivity);

        findViewById(R.id.compete_newadd).setOnClickListener(this);
        mBodyLinearLayout = (LinearLayout)findViewById(R.id.compete_body);
    }

    /**
     * (non-Javadoc)
     * @see android.view.View.OnClickListener#onClick(android.view.View)
     */
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        if(v != null){
            switch(v.getId()){
                case R.id.compete_newadd: //新增
                    break;
            }
        }
    }

    /**
     * 设置选项数据
     * @param brandsList 品牌选项
     * @param activitysList 活动选项
     */
    public void setChoiceviewList(List<DataItem> brandsList, List<DataItem> activitysList){
        mBrandChoiceview.setChoiceDataList(brandsList);
        mPromotionsChoiceview.setChoiceDataList(activitysList);
    }
}
